package com.hzvictory.hotel_system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hzvictory.hotel_system.common.annotation.Log;
import com.hzvictory.hotel_system.common.core.controller.BaseController;
import com.hzvictory.hotel_system.common.core.domain.AjaxResult;
import com.hzvictory.hotel_system.common.enums.BusinessType;
import com.hzvictory.hotel_system.pojo.entity.Seat;
import com.hzvictory.hotel_system.service.ISeatService;
//import com.hzvictory.hotel_system.common.utils.poi.ExcelUtil;
import com.hzvictory.hotel_system.common.core.page.TableDataInfo;

/**
 * 功能:座位Controller
 * 作者：何征
 * 日期：2025/7/23 17:40
 */

@RestController
@RequestMapping("/system/seat")
public class SeatController extends BaseController
{
    @Autowired
    private ISeatService seatService;

    /**
     * 查询座位列表
     */
    //@PreAuthorize("@ss.hasPermi('system:seat:list')")
    @GetMapping("/list")
    public TableDataInfo list(Seat seat)
    {
        startPage();
        List<Seat> list = seatService.selectSeatList(seat);
        return getDataTable(list);
    }

    /**
     * 导出座位列表
     */
    //@PreAuthorize("@ss.hasPermi('system:seat:export')")
//    @Log(title = "座位", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Seat seat)
//    {
//        List<Seat> list = seatService.selectSeatList(seat);
//        ExcelUtil<Seat> util = new ExcelUtil<Seat>(Seat.class);
//        util.exportExcel(response, list, "座位数据");
//    }

    /**
     * 获取座位详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:seat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(seatService.selectSeatById(id));
    }

    /**
     * 新增座位
     */
    //@PreAuthorize("@ss.hasPermi('system:seat:add')")
    @Log(title = "座位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Seat seat)
    {
        return toAjax(seatService.insertSeat(seat));
    }

    /**
     * 修改座位
     */
    //@PreAuthorize("@ss.hasPermi('system:seat:edit')")
    @Log(title = "座位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Seat seat)
    {
        return toAjax(seatService.updateSeat(seat));
    }

    /**
     * 修改座位状态：空闲1-》0 已预订
     */

    //@Log(title = "座位", businessType = BusinessType.UPDATE)
    @PutMapping("/status")
    public AjaxResult editStatus(@RequestParam Long id)
    {
        return toAjax(seatService.updateSeatStatus(id));
    }
    /**
     * 删除座位
     */
    //@PreAuthorize("@ss.hasPermi('system:seat:remove')")
    @Log(title = "座位", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(seatService.deleteSeatByIds(ids));
    }
}
